package com.cuit.bysj.InterfaceAction;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cuit.bysj.entities.Student;
import com.cuit.bysj.entities.Teacher;
import com.cuit.bysj.service.StuService;
import com.cuit.bysj.service.TcherService;
import com.opensymphony.xwork2.ActionSupport;

public class androidHumanmgr extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private TcherService tcherService;
	private StuService stuService;
	private Map<String, Object> dataMap;
	private String sex;
	private String banji;
	private String age;
	private String major;
	private String id;
	private String academic;
	private String college;

	public String getAcademic() {
		return academic;
	}

	public void setAcademic(String academic) {
		this.academic = academic;
	}

	public String getCollege() {
		return college;
	}

	public void setCollege(String college) {
		this.college = college;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getBanji() {
		return banji;
	}

	public void setBanji(String banji) {
		this.banji = banji;
	}

	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}

	public String getMajor() {
		return major;
	}

	public void setMajor(String major) {
		this.major = major;
	}

	public void setDataMap(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	}

	public void settcherService(TcherService tcherService) {
		this.tcherService = tcherService;
	}

	public void setstuService(StuService stuService) {
		this.stuService = stuService;
	}

	public Map<String, Object> getDataMap() {
		return dataMap;
	}

	@SuppressWarnings("rawtypes")
	public String stuList() {
		List list = stuService.stulist();

		dataMap = new HashMap<String, Object>();
		dataMap.put("stulist", list);

		return "json";
	}

	public String updatestu() {
		Student stu = stuService.findStu(Integer.parseInt(id));
		stu.setBanji(banji);
		stu.setAge(age);
		stu.setMajor(major);
		stu.setSex(sex);
		stuService.updateStu(stu);

		dataMap = new HashMap<String, Object>();
		dataMap.put("code", "修改成功!");

		return "json";
	}

	public String updatetcher() {
		Teacher tcher = tcherService.findTcher(Integer.parseInt(id));
		tcher.setAge(age);
		tcher.setSex(sex);
		tcher.setAcademic(academic);
		tcher.setCollege(college);
		tcherService.updateTcher(tcher);

		dataMap = new HashMap<String, Object>();
		dataMap.put("code", "修改成功!");

		return "json";
	}

	@SuppressWarnings("unchecked")
	public String tcherlist() {
		List<Teacher> list = tcherService.tcherlist();

		dataMap = new HashMap<String, Object>();
		dataMap.put("tcherlist", list);

		return "json";
	}
}
